Blog

Brad Wood

December 21, 2016

Spread the word


Share your thoughts

Christmas is almost here and if you listen carefully you can probably hear the jingling bells on Santa's sleigh.  If you listen even harder, you can hear the cries of anguish from CF developers around the world who's server won't boot and they need to track down the console log!  In this next installment of the 12 Tips of (CommandBox) Christmas, we've got some help.

Server Logs

Whenever a CF server starts, there's a log file that captures the output that would have been sent to the console.  This can differ based on your servlet container, whether you're using Lucee or Adobe CF.  In CommandBox, we put the server's "out" log in the same place and give you an easy command to spill the contents of the log file:

CommandBox> server log

If you've been starting more than one server by name in the same folder, you can request each log file via the name of the server just like the rest of the server commands.

CommandBox> server log server1
CommandBox> server log server2

Too much text?  No worries, just pipe that unruly output through the more command for pagination or the tail command to view the last X number of lines.  Note: even if you're on Windows you can still use features like tail in the interactive CommandBox shell since we emulate the most common and useful bash operations for you.

CommandBox> server log | more
CommandBox> server log | tail lines=100

But wait, there's more

We've also got some cool new features cooking up on the bleeding edge of CommandBox which we'll be releasing soon.  You can grab this pre-release version here.

The first new feature is the ability to live-stream the console output (as well as other useful debugging information) to the console as the server starts. Once the server comes up and we open the browser window, we'll stop streaming and return you to the command prompt.  To get this behavior, just use the --debug flag when starting your server.

CommandBox> server start --debug

Oops, you just started your server and forgot the flag, but now you want to watch it come up?  No problem, the server log command we covered earlier has a new trick up its sleeve.  Add the --follow flag to server log and you'll immediately begin tailing the server's console output until you press Ctrl-C to quit.  This feature defers a the new --follow flag on CommandBox's tail command which allows you to live-tail ANY file you wish including application logs.

CommandBox> server log --follow

And finally, if you want to simulate the old behavior of starting your CF server from the command line, where the process runs in the foreground until you stop it, you can do this as well with the new --console flag on the server start command.  This will start the CF server in the foreground and live-stream the output to the console for as long as the server is up.  To stop, press Ctrl-C and CommandBox will stop the server and return you to the command line.

CommandBox> server log --console

 

 

Add Your Comment

(3)

Sep 13, 2017 05:28:38 UTC

by Mark Drew

Would you be able to also define which log you are following? for example application or mail?

Sep 13, 2017 08:18:00 UTC

by Brad Wood

Hi Mark, right now the "server log" command will just look at the servlet's "out" log. I like the idea of specifying another log, but I'm not sure how to combine servers since Adobe and Lucee have slightly different log files. Plus Lucee has two sets, one server context log dir and one web context log dir which can be confusing. Another idea we had was to make "server log --follow" somehow combine all log files at the same time for that engine into one stream. https://ortussolutions.atlassian.net/browse/COMMANDBOX-604

Sep 13, 2017 08:23:58 UTC

by Mark Drew

Using --follow would make sense and in essence for Lucee it would be an aggregation of the server and context logs. The server logs would be fairly quiet to be honest. It's confusing but the server logs would tell you about extensions. So basically --follow might be an answer and then you can grep it if you add something like "server/application.log" or (in ACF case) "application.log" (as per the ticket) Having the name highlighted before each entry how docker-compose does it would do the trick nicely!

Recent Entries

Partner with BoxLang and Ortus at Into the Box 2025: Empowering the Future of Modern Software Development!

Partner with BoxLang and Ortus at Into the Box 2025: Empowering the Future of Modern Software Development!

At Ortus Solutions, we’ve always been at the forefront of innovation in the ColdFusion ecosystem. From pioneering modern ColdFusion practices to developing cutting-edge tools and frameworks, we’ve been passionate to help and sup[port the community into shaping the future of web development.That’s why we decided to build BoxLang, our new JVM programming language that not only builds on the strengths of ColdFusion but takes modern software development to the next level.

Maria Jose Herrera
Maria Jose Herrera
December 23, 2024
Why BoxLang When You Have Kotlin, Groovy, Scala, and more…

Why BoxLang When You Have Kotlin, Groovy, Scala, and more…

As we approach a stable release of BoxLang and our continued marketing reaches more folks, many have asked about its purpose. Why create a new language when the JVM ecosystem already includes established languages like Kotlin, Groovy, and Scala, to name a few.

Luis Majano
Luis Majano
December 18, 2024